import pymysql
import json

with open('piaofang.json' , 'r',encoding='utf-8') as file:
    data = json.load(file)
db = pymysql.connect(host='localhost',user='root',password='123456',database='film')

cursor = db.cursor()
for i in data["list"]:
    movieName = i["movieInfo"]["movieName"]
    sumBoxDesc = i["sumBoxDesc"]
    releaseInfo = i["movieInfo"]["releaseInfo"]
    sql = "INSERT INTO `piaofang` (`filmname`,`money`,`time`) VALUES (%s,%s,%s)"
    print(sql, movieName, sumBoxDesc, releaseInfo)
    cursor.execute(sql, (movieName, sumBoxDesc, releaseInfo))
db.commit() 

db.close()
